<?php
    include '../connectDatabase.php';

    session_start();
    //if(isset($_COOKIE["modifyid"])){
        //$ID = $_COOKIE['modifyid'];
    $ID = $_SESSION['modifyid'];
    $type = $_SESSION['modifytype'];
    //}
    $username = $_POST['username'];
    $passwd = $_POST['passwd'];
    $email = $_POST['email'];
    $sex = $_POST['sex'];
    
    $usertype = $_SESSION['type'];
    if($usertype != "超级管理员" && $type == "管理员"){
        echo "<script>alert('您的权限不足！');window.location.href='../Page/look_user.php';</script>" ;
    }
 
    $sql = "update users set user_name='$username',user_password='$passwd',user_sex='$sex',user_email='$email' where user_id='$ID'";
    $result=mysqli_query($conn, $sql);


    if($result){
        echo "<script>alert('修改成功');window.location.href='../Page/look_user.php';</script>" ;
    }else{
        echo "<script>alert('修改失败');history.go(-1);</script>";
    }
 ?>